package controller

import (
	"elegantGo/chapter17/controller/response"
	"elegantGo/chapter17/repository"
	"elegantGo/chapter17/repository/ent"
	"github.com/gin-gonic/gin"
)

type Vip struct {
	repo *repository.Vip
}

func NewVip(repo *repository.Vip) *Vip {
	ctr := new(Vip)
	ctr.repo = repo
	return ctr
}

func (ctr *Vip) Many(c *gin.Context) (response.Data, error) {
	ooVips := ctr.repo.FetchMany(c.Request.Context(), func(opt *ent.VipQuery) {
		opt.Limit(10)
	})
	return ooVips.Mapper(), nil
}
